<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <title>test</title>
    <script src="../static/js/vue.js"></script>
    <script src="../static/js/jquery-3.3.1.js"></script>
    <script src="../static/js/bootstrap.js"></script>
    <link rel="stylesheet" href="../static/css/bootstrap.css"/>
</head>
<body>
<div id="app">
    <input type="text" v-model="userName">
    <button @click="login">用户信息</button>
    <table class="table table-striped">
        <thead>
        <tr>
            <th scope="col">id</th>
            <th scope="col">username</th>
            <th scope="col">nickname</th>
            <th scope="col">sex</th>
        </tr>
        </thead>
        <tbody>
        <tr v-for="user in result.list">
            <td>{{user.id}}</td>
            <td>{{user.username}}</td>
            <td>{{user.nickName}}</td>
            <td>{{user.sex}}</td>
        </tr>
        <tr>
            <td>{{result.id}}</td>
            <td>{{result.username}}</td>
            <td>{{result.nickName}}</td>
            <td>{{result.sex}}</td>
        </tr>
        </tbody>
    </table>
</div>

</body>
<script>
    var app=new Vue({
        el:'#app',
        data:{
            userName:'',
            passWord:'',
            result:''
        },
        methods: {
            login: function () {
                var da = {username:app.userName,password:app.passWord};
                debugger;
                $.ajax({
                    url:'/users/list',
                    method:'post',
                    data:da,
                    success:function(text){
                        debugger;
                        if(text.data!==null){
                            app.result = text.data;
                        }
                    }
                });
            }
        }
    })
</script>
</html>